package GUI;

import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JTextField;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JButton;

import Client.BusinessImplements;

import java.awt.SystemColor;
import java.awt.Font;
import java.awt.Color;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.border.LineBorder;

public class Finding_Item_To_Add_copy_Of_It extends Abstract_Jpanel {
	private JTextField txtId;
	JButton btnApply;
	JButton btnBack ;
	/**
	 * in this panel you choose to which Item you want to add a copy
	 */
	public Finding_Item_To_Add_copy_Of_It() {
		
		JPanel panel = new JPanel();
		panel.setBorder(new LineBorder(SystemColor.activeCaption, 6));
		panel.setBounds(10, 67, 562, 223);
		panel.setBackground(SystemColor.inactiveCaption);
		
		JLabel lblChoseId = new JLabel("Choose Book Id to add a copy");
		lblChoseId.setBounds(10, 11, 536, 50);
		lblChoseId.setForeground(new Color(25, 25, 112));
		lblChoseId.setFont(new Font("MV Boli", Font.BOLD, 30));
		
		JPanel panel_1 = new JPanel();
		panel_1.setBounds(20, 302, 552, 50);
			 panel_1.setLayout(null);
		
			 btnBack = new JButton("back");
			 btnBack.setBounds(10, 11, 90, 36);
			 panel_1.add(btnBack);
			 
			 
			 btnBack.addActionListener(new ActionListener() {
			 	public void actionPerformed(ActionEvent e) {
			 		
			 		Sign_in_panel sip=new Sign_in_panel();
					on_screen_unload();
					BusinessImplements.GetInstance().getMainFrame().setContentPane(sip);
					sip.setSize(getMaximumSize());
					sip.on_screen_load();
					
			 	}
			 });
			 btnBack.setFont(new Font("Tahoma", Font.PLAIN, 14));
		btnApply = new JButton("Apply");
		btnApply.setBounds(413, 11, 90, 36);
		panel_1.add(btnApply);
		btnApply.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				Managment_panel mng_panel=new Managment_panel();
				if (BusinessImplements.GetInstance().getServerProxy().ItemExistsByID(txtId.getText()).get(0).toString().equals("true"))
				{
					mng_panel.add_copy.setItemID(txtId.getText());
					on_screen_unload();
					BusinessImplements.GetInstance().getMainFrame().setContentPane(mng_panel.add_copy);
					mng_panel.add_copy.setSize(getMaximumSize());
					mng_panel.add_copy.on_screen_load();
				}
				else
					JOptionPane.showMessageDialog(null, "the item not exist in the system!");
				
				
				
				
			}
		});
		btnApply.setFont(new Font("Tahoma", Font.PLAIN, 14));
		setLayout(null);
		panel.setLayout(null);
		
		JLabel lblItemId = new JLabel("Item ID: ");
		lblItemId.setFont(new Font("Tahoma", Font.PLAIN, 14));
		lblItemId.setBounds(86, 40, 59, 14);
		panel.add(lblItemId);
		
		txtId = new JTextField();
		txtId.setBounds(174, 39, 119, 20);
		panel.add(txtId);
		txtId.setColumns(10);
		
		JLabel lblPleaseInsertThe = new JLabel("Please insert the ID of the Item you want to add a copy");
		lblPleaseInsertThe.setForeground(Color.RED);
		lblPleaseInsertThe.setBounds(73, 86, 430, 26);
		panel.add(lblPleaseInsertThe);
		lblPleaseInsertThe.setFont(new Font("Segoe Print", Font.PLAIN, 14));
		add(panel);
		add(panel_1);
		add(lblChoseId);

	}

	@Override
	public void next_screen() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void prev_screen() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void on_screen_load() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void on_screen_unload() {
		// TODO Auto-generated method stub
		
	}

}
